/**
 * @param {string[]} arr
 * @return {number}
 */
var maxLength = function (arr) {
  let temp = []
  let ans = 0
  function dfs (list, index) {
    if (list.length > arr.length + 1) {
      return
    }
    let suitStr = list.join("")
    if (!hasSameStr(suitStr)) temp.push(suitStr)
    for (let i=index; i<arr.length; i++) {
      list.push(arr[i])
      dfs(list, i + 1)
      list.pop()
    }
  }
  dfs([""], 0)
  return Math.max(...(temp.map(v => v.length)))
};

var hasSameStr = function (str) {
  let strArr = Array.from(str)
  let set = new Set(strArr)
  return set.size !== strArr.length
}

console.log(maxLength(["un","iq","ue"]));